import java.util.Scanner;

public class test4 {
    //写一个递归方法，输入一个非负整数，返回组成它的数字之和
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入数字:");
        int n = sc.nextInt();
        int sum = 0;
        getPrint(n,sum);
    }
    public static void getPrint(int n,int sum){
        int b = n%10;
        System.out.print(b+" ");
        sum += b;
        n = n/10;
        if(n==0){
            System.out.println("输出结束!");
            System.out.println("数字的和为:"+sum);
        }else{
            getPrint(n,sum);
        }
    }
}
